Page({
  data: {
    gridItems: [
      { imgUrl: "/images/food-images/grain.png", text: '谷物', tag: '健肠' },
      { imgUrl: "/images/food-images/fruit.png", text: '应季水果', tag: '抗氧' },
      { imgUrl: "/images/food-images/vegetable.png", text: '绿色蔬菜', tag: '免疫' },
      { imgUrl: "/images/food-images/bean.png", text: '豆类', tag: '降脂' },
      { imgUrl: "/images/food-images/nut.png", text: '坚果', tag: '养心' },
      { imgUrl: "/images/food-images/meat.png", text: '肉类', tag: '补铁' },
    ]
  },

  gridTap(e) {
    const index = e.currentTarget.dataset.index;  // 获取点击项的索引
    const selectedItem = this.data.gridItems[index];  // 获取点击项的数据
    // 跳转到食物列表页面，并传递点击的类别数据
    wx.navigateTo({
      url: `/foodLists/pages/foodList/foodList?category=${selectedItem.text}`,
    });
  }
});


